<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var src1="";

    function convertBase64UrlToBlob(urlData){

        var bytes=window.atob(urlData.split(',')[1]);        //去掉url的头，并转换为byte

        //处理异常,将ascii码小于0的转换为大于0
        var ab = new ArrayBuffer(bytes.length);
        var ia = new Uint8Array(ab);
        for (var i = 0; i < bytes.length; i++) {
            ia[i] = bytes.charCodeAt(i);
        }

        return new File( [ab] , {type : 'image/png'});
       // return new Blob( [ab] , {type : 'image/png'});
    }

    var reader = new FileReader();
    reader.onload = function(event) {
        debugger
        var dataUri = event.target.result,
            img     = document.createElement("img");

        img.src = dataUri;
        document.body.appendChild(img);
    };

    reader.onerror = function(event) {
        console.error("File could not be read! Code " + event.target.error.code);
    };

    var d = convertBase64UrlToBlob(src1);

//    reader.readAsDataURL();

    function dataURLtoFile(dataurl, filename) { //将base64转换为文件
        var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
            bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
        while(n--){
            u8arr[n] = bstr.charCodeAt(n);
        }
        return new File([u8arr], filename, {type:mime});
    }
    var files = dataURLtoFile(src1,"dd.png");
    debugger
</script>
</body>
</html>